/*    */ package com.zimbra.cs.account.callback;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.AttributeCallback;
/*    */ import com.zimbra.cs.account.AttributeCallback.MultiValueMod;
/*    */ import com.zimbra.cs.account.AttributeManager;
/*    */ import com.zimbra.cs.account.AttributeManager.IDNType;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.IDNUtil;
/*    */ import java.util.HashSet;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class IDNCallback
/*    */   extends AttributeCallback
/*    */ {
/*    */   public void preModify(CallbackContext context, String attrName, Object value, Map attrsToModify, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 43 */     AttributeCallback.MultiValueMod mod = multiValueMod(attrsToModify, attrName);
/* 44 */     AttributeManager.IDNType idnType = AttributeManager.idnType(AttributeManager.getInstance(), attrName);
/*    */     
/* 46 */     if ((mod.adding()) || (mod.replacing())) {
/* 47 */       Set<String> asciiValues = new HashSet();
/* 48 */       List<String> addrs = mod.values();
/* 49 */       for (String addr : addrs) {
/* 50 */         if ((addr != null) && (!addr.equals(""))) {
/*    */           String asciiName;
/*    */           String asciiName;
/* 53 */           if (addr.charAt(0) == '@')
/*    */           {
/* 55 */             asciiName = "@" + IDNUtil.toAsciiDomainName(addr.substring(1));
/*    */           } else {
/* 57 */             asciiName = IDNUtil.toAscii(addr, idnType);
/*    */           }
/*    */           
/* 60 */           asciiValues.add(asciiName);
/*    */         }
/*    */       }
/* 63 */       String aName = (mod.adding() ? "+" : "") + attrName;
/* 64 */       attrsToModify.remove(aName);
/* 65 */       attrsToModify.put(aName, asciiValues.toArray(new String[asciiValues.size()]));
/*    */     }
/*    */   }
/*    */   
/*    */   public void postModify(CallbackContext context, String attrName, Entry entry) {}
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/callback/IDNCallback.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */